package com.life.muyu.controller;

import com.life.muyu.mapper.ClientMapper;
import com.life.muyu.model.Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author zyb
 * @Date 2020-04-01 4:20 PM
 **/
@Controller
public class ClientController {

    @Autowired
    private ClientMapper clientMapper;

    @GetMapping("/client")
    public String toClient(Model model){
        model.addAttribute("clients",clientMapper.selectList(null));
        return "client";
    }

    @ResponseBody
    @PostMapping("/client")
    public List<Client> getClients(){
        return clientMapper.selectList(null);
    }
}
